﻿using Microsoft.Extensions.DependencyInjection;

namespace RuoVea.ExGlobal
{
    /// <summary>
    /// IOptions 扩展
    /// </summary>
    public static class IOptions
    {
        /// <summary>
        /// 注入 全局异常处理 
        /// </summary>
        /// <param name="services"></param>
        public static void GlobalException(this IServiceCollection services)
        {
            services.AddMvcCore(options =>
            {
                //全局注册
                options.Filters.Add<GlobalExceptionFilter>();
            });
        }

        /// <summary>
        /// 注入 请求日志拦截
        /// </summary>
        public static void GlobalRequestAction(this IServiceCollection services)
        {
            services.AddMvcCore(options =>
            {
                //全局注册
                options.Filters.Add(typeof(RequestActionFilter));
            });
        }
    }
}
